import {getStore, setStore,} from '@/util/store'
import website from '@/config/website'

const common = {
    state: {
        language: getStore({name: 'language'}) || 'en',
        isCollapse: false,
        isFullScren: false,
        isMenu: true,
        isShade: false,
        screen: -1,
        showTag: true,
        showDebug: true,
        showCollapse: true,
        showSearch: true,
        showLock: true,
        showFullScren: true,
        showTheme: true,
        showColor: true,
        colorName: getStore({name: 'colorName'}) || '#409EFF',
        themeName: getStore({name: 'themeName'}) || 'theme-vip',
        website: website,
    },
    mutations: {
        SET_LANGUAGE: (state, language) => {
            state.language = language
            setStore({
                name: 'language',
                content: state.language
            })
        },
        SET_SHADE: (state, active) => {
            state.isShade = active;
        },
        SET_COLLAPSE: (state) => {
            state.isCollapse = !state.isCollapse;
        },
        SET_IS_MENU: (state, menu) => {
            state.isMenu = menu;
        },
        SET_FULLSCREN: (state) => {
            state.isFullScren = !state.isFullScren;
        },
        SET_SCREEN: (state, screen) => {
            state.screen = screen;
        },
        SET_COLOR_NAME: (state, colorName) => {
            state.colorName = colorName;
            setStore({
                name: 'colorName',
                content: state.colorName,
            })
        },
        SET_THEME_NAME: (state, themeName) => {
            state.themeName = themeName;
            setStore({
                name: 'themeName',
                content: state.themeName,
            })
        },
    }
}
export default common
